package cn.lutu.lutu.service.impl;

import cn.lutu.lutu.mapper.HotelsMapper;
import cn.lutu.lutu.pojo.dto.HotelDTO;
import cn.lutu.lutu.pojo.dto.RoomDTO;
import cn.lutu.lutu.pojo.entity.Hotel;
import cn.lutu.lutu.pojo.entity.Room;
import cn.lutu.lutu.pojo.vo.HotelVO;
import cn.lutu.lutu.pojo.vo.RoomVO;
import cn.lutu.lutu.response.ResultVO;
import cn.lutu.lutu.service.HotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class HotelServiceImpl implements HotelService {
    @Autowired
    HotelsMapper mapper;

    @Override
    public void insertHotel(HotelDTO hotelDTO) {
        Hotel hotel = new Hotel();
        BeanUtils.copyProperties(hotelDTO, hotel);
        mapper.insert(hotel);
    }

    @Override
    public void insertRoom(RoomDTO roomDTO){
        Room room = new Room();
        BeanUtils.copyProperties(roomDTO,room);
        mapper.insertRoom(room);
    }

    @Override
    public void updateById(HotelDTO hotelDTO) {
        Hotel hotel = new Hotel();
        BeanUtils.copyProperties(hotelDTO,hotel);
        log.debug("hotel="+hotel);
        mapper.updateById(hotel);
    }

    @Override
    public void updateRoom(RoomDTO roomDTO) {
        Room room = new Room();
        BeanUtils.copyProperties(roomDTO,room);
        mapper.updateRoom(room);
    }

    @Override
    public void deleteHotelById(Long id) {
        mapper.deleteHotelById(id);
    }

    @Override
    public void deleteById(Long id) {
        mapper.deleteById(id);
    }

    @Override
    public HotelVO selectHotel(Long id) {
        HotelVO hotelVO=mapper.selectHotel(id);
        //查询功能
        return hotelVO;
    }

    @Override
    public RoomVO selectRoom(Long id) {
        RoomVO roomVO = mapper.selectRoom(id);
        return roomVO;
    }
}
